package com.inibb.app.converter;


import com.inibb.app.po.security.Role;
import com.inibb.app.vo.security.RoleDTO;

public class RoleConverter extends DTOConverter<Role, RoleDTO> {

	private AuthorityConverter authConverter = new AuthorityConverter();

	public RoleDTO toDTO(Role role) {
		if (null == role)
			return null;

		RoleDTO roleDTO = new RoleDTO();

		roleDTO.setId(role.getId());
		roleDTO.setName(role.getName());
		roleDTO.setAuths(authConverter.toDTOs(role.getAuths()));

		return roleDTO;
	}

	public Role toPO(RoleDTO roleDTO) {
		if (null == roleDTO)
			return null;

		Role role = new Role();

		role.setId(roleDTO.getId());
		role.setName(roleDTO.getName());
		role.setAuths(authConverter.toPOs(roleDTO.getAuths()));

		return role;
	}

}
